import request, { METHOD } from '@/service/request.service';


export function getGood(){
  uni.showLoading();
  return request({
    url: '/good/:id',
    method: METHOD.GET,
  }).then((response)=> {
    uni.hideLoading();
    return response
  }).catch((error) => {
    uni.hideLoading();
    return error
  })
}
export function getGoodList(){
  return request({
    url: '/goods',
    method: METHOD.GET,
  })
}
export function createGood(data){
  uni.showLoading();
  
  return request({
    url: '/good',
    method: METHOD.POST,
    data
  }).then((response)=> {
    uni.hideLoading();
    uni.showToast({
      title: '创建成功',
      duration: 1000
    });
    return response
  }).catch((error) => {
    uni.hideLoading();
    return error
  })
}
export function modifyGood(){
  return request({
    url: '/good/:id',
    method: METHOD.PUT,
  })
}



export function getCollectGoodList(userId){
  return request({
    url: '/good/collect/:userId',
    method: METHOD.GET,
  })
}


